// $ANTLR 3.2 Sep 23, 2009 12:02:23 C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g 2010-01-28 23:44:46

package com.area42games.grammar;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class DiceParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "SEMI", "EACH", "PLUS", "MINUS", "MULT", "DIV", "D", "CD", "QUESTION", "DOT", "COMMA", "COLON", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "HASH", "NUMBER", "COMP", "QUALIFIER", "HIGH", "LOW", "REROLL", "ROLLAGAIN", "IDENTIFIER", "EQ", "DIGIT", "LETTER", "WHITESPACE"
    };
    public static final int D=10;
    public static final int RBRACE=19;
    public static final int QUALIFIER=23;
    public static final int LETTER=31;
    public static final int LBRACE=18;
    public static final int NUMBER=21;
    public static final int HASH=20;
    public static final int WHITESPACE=32;
    public static final int COMP=22;
    public static final int MINUS=7;
    public static final int MULT=8;
    public static final int EOF=-1;
    public static final int LOW=25;
    public static final int SEMI=4;
    public static final int ROLLAGAIN=27;
    public static final int LPAREN=16;
    public static final int COLON=15;
    public static final int RPAREN=17;
    public static final int QUESTION=12;
    public static final int HIGH=24;
    public static final int COMMA=14;
    public static final int IDENTIFIER=28;
    public static final int PLUS=6;
    public static final int DIGIT=30;
    public static final int EACH=5;
    public static final int EQ=29;
    public static final int DIV=9;
    public static final int CD=11;
    public static final int DOT=13;
    public static final int REROLL=26;

    // delegates
    // delegators


        public DiceParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public DiceParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return DiceParser.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g"; }


    List<Object> expressions = new ArrayList<Object>();


    public static class exprList_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "exprList"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:44:1: exprList : ( expr SEMI )+ ;
    public final DiceParser.exprList_return exprList() throws RecognitionException {
        DiceParser.exprList_return retval = new DiceParser.exprList_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token SEMI2=null;
        DiceParser.expr_return expr1 = null;


        CommonTree SEMI2_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:45:3: ( ( expr SEMI )+ )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:45:5: ( expr SEMI )+
            {
            root_0 = (CommonTree)adaptor.nil();

            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:45:5: ( expr SEMI )+
            int cnt1=0;
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( ((LA1_0>=SEMI && LA1_0<=MINUS)||LA1_0==QUESTION||LA1_0==LPAREN||(LA1_0>=NUMBER && LA1_0<=COMP)||LA1_0==IDENTIFIER) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:45:6: expr SEMI
            	    {
            	    pushFollow(FOLLOW_expr_in_exprList223);
            	    expr1=expr();

            	    state._fsp--;

            	    adaptor.addChild(root_0, expr1.getTree());
            	    SEMI2=(Token)match(input,SEMI,FOLLOW_SEMI_in_exprList225); 

            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "exprList"

    public static class expr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "expr"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:48:1: expr : altExpr ( EACH altExpr )? ;
    public final DiceParser.expr_return expr() throws RecognitionException {
        DiceParser.expr_return retval = new DiceParser.expr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token EACH4=null;
        DiceParser.altExpr_return altExpr3 = null;

        DiceParser.altExpr_return altExpr5 = null;


        CommonTree EACH4_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:49:2: ( altExpr ( EACH altExpr )? )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:49:4: altExpr ( EACH altExpr )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_altExpr_in_expr242);
            altExpr3=altExpr();

            state._fsp--;

            adaptor.addChild(root_0, altExpr3.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:49:12: ( EACH altExpr )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==EACH) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:49:13: EACH altExpr
                    {
                    EACH4=(Token)match(input,EACH,FOLLOW_EACH_in_expr245); 
                    EACH4_tree = (CommonTree)adaptor.create(EACH4);
                    root_0 = (CommonTree)adaptor.becomeRoot(EACH4_tree, root_0);

                    pushFollow(FOLLOW_altExpr_in_expr248);
                    altExpr5=altExpr();

                    state._fsp--;

                    adaptor.addChild(root_0, altExpr5.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expr"

    public static class altExpr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "altExpr"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:53:1: altExpr : comparison ( QUESTION caselist | QUESTION thenElse )? ;
    public final DiceParser.altExpr_return altExpr() throws RecognitionException {
        DiceParser.altExpr_return retval = new DiceParser.altExpr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token QUESTION7=null;
        Token QUESTION9=null;
        DiceParser.comparison_return comparison6 = null;

        DiceParser.caselist_return caselist8 = null;

        DiceParser.thenElse_return thenElse10 = null;


        CommonTree QUESTION7_tree=null;
        CommonTree QUESTION9_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:54:2: ( comparison ( QUESTION caselist | QUESTION thenElse )? )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:54:4: comparison ( QUESTION caselist | QUESTION thenElse )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_comparison_in_altExpr262);
            comparison6=comparison();

            state._fsp--;

            adaptor.addChild(root_0, comparison6.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:54:15: ( QUESTION caselist | QUESTION thenElse )?
            int alt3=3;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==QUESTION) ) {
                int LA3_1 = input.LA(2);

                if ( (LA3_1==LBRACE) ) {
                    alt3=1;
                }
                else if ( ((LA3_1>=PLUS && LA3_1<=MINUS)||LA3_1==QUESTION||(LA3_1>=COLON && LA3_1<=LPAREN)||(LA3_1>=NUMBER && LA3_1<=COMP)||LA3_1==IDENTIFIER) ) {
                    alt3=2;
                }
            }
            switch (alt3) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:54:17: QUESTION caselist
                    {
                    QUESTION7=(Token)match(input,QUESTION,FOLLOW_QUESTION_in_altExpr266); 
                    QUESTION7_tree = (CommonTree)adaptor.create(QUESTION7);
                    root_0 = (CommonTree)adaptor.becomeRoot(QUESTION7_tree, root_0);

                    pushFollow(FOLLOW_caselist_in_altExpr269);
                    caselist8=caselist();

                    state._fsp--;

                    adaptor.addChild(root_0, caselist8.getTree());

                    }
                    break;
                case 2 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:54:38: QUESTION thenElse
                    {
                    QUESTION9=(Token)match(input,QUESTION,FOLLOW_QUESTION_in_altExpr273); 
                    QUESTION9_tree = (CommonTree)adaptor.create(QUESTION9);
                    root_0 = (CommonTree)adaptor.becomeRoot(QUESTION9_tree, root_0);

                    pushFollow(FOLLOW_thenElse_in_altExpr276);
                    thenElse10=thenElse();

                    state._fsp--;

                    adaptor.addChild(root_0, thenElse10.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "altExpr"

    public static class thenElse_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "thenElse"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:57:1: thenElse : altExpr COLON altExpr ;
    public final DiceParser.thenElse_return thenElse() throws RecognitionException {
        DiceParser.thenElse_return retval = new DiceParser.thenElse_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token COLON12=null;
        DiceParser.altExpr_return altExpr11 = null;

        DiceParser.altExpr_return altExpr13 = null;


        CommonTree COLON12_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:57:10: ( altExpr COLON altExpr )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:57:12: altExpr COLON altExpr
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_altExpr_in_thenElse288);
            altExpr11=altExpr();

            state._fsp--;

            adaptor.addChild(root_0, altExpr11.getTree());
            COLON12=(Token)match(input,COLON,FOLLOW_COLON_in_thenElse290); 
            COLON12_tree = (CommonTree)adaptor.create(COLON12);
            root_0 = (CommonTree)adaptor.becomeRoot(COLON12_tree, root_0);

            pushFollow(FOLLOW_altExpr_in_thenElse293);
            altExpr13=altExpr();

            state._fsp--;

            adaptor.addChild(root_0, altExpr13.getTree());

            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "thenElse"

    public static class eachExpr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "eachExpr"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:59:1: eachExpr : factor EACH altExpr ;
    public final DiceParser.eachExpr_return eachExpr() throws RecognitionException {
        DiceParser.eachExpr_return retval = new DiceParser.eachExpr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token EACH15=null;
        DiceParser.factor_return factor14 = null;

        DiceParser.altExpr_return altExpr16 = null;


        CommonTree EACH15_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:60:2: ( factor EACH altExpr )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:60:4: factor EACH altExpr
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_factor_in_eachExpr302);
            factor14=factor();

            state._fsp--;

            adaptor.addChild(root_0, factor14.getTree());
            EACH15=(Token)match(input,EACH,FOLLOW_EACH_in_eachExpr304); 
            EACH15_tree = (CommonTree)adaptor.create(EACH15);
            root_0 = (CommonTree)adaptor.becomeRoot(EACH15_tree, root_0);

            pushFollow(FOLLOW_altExpr_in_eachExpr307);
            altExpr16=altExpr();

            state._fsp--;

            adaptor.addChild(root_0, altExpr16.getTree());

            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "eachExpr"

    public static class caselist_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "caselist"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:62:1: caselist : LBRACE caseexpr ( COMMA caseexpr )* RBRACE ;
    public final DiceParser.caselist_return caselist() throws RecognitionException {
        DiceParser.caselist_return retval = new DiceParser.caselist_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token LBRACE17=null;
        Token COMMA19=null;
        Token RBRACE21=null;
        DiceParser.caseexpr_return caseexpr18 = null;

        DiceParser.caseexpr_return caseexpr20 = null;


        CommonTree LBRACE17_tree=null;
        CommonTree COMMA19_tree=null;
        CommonTree RBRACE21_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:63:2: ( LBRACE caseexpr ( COMMA caseexpr )* RBRACE )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:63:4: LBRACE caseexpr ( COMMA caseexpr )* RBRACE
            {
            root_0 = (CommonTree)adaptor.nil();

            LBRACE17=(Token)match(input,LBRACE,FOLLOW_LBRACE_in_caselist318); 
            LBRACE17_tree = (CommonTree)adaptor.create(LBRACE17);
            root_0 = (CommonTree)adaptor.becomeRoot(LBRACE17_tree, root_0);

            pushFollow(FOLLOW_caseexpr_in_caselist321);
            caseexpr18=caseexpr();

            state._fsp--;

            adaptor.addChild(root_0, caseexpr18.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:63:21: ( COMMA caseexpr )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( (LA4_0==COMMA) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:63:22: COMMA caseexpr
            	    {
            	    COMMA19=(Token)match(input,COMMA,FOLLOW_COMMA_in_caselist324); 
            	    pushFollow(FOLLOW_caseexpr_in_caselist327);
            	    caseexpr20=caseexpr();

            	    state._fsp--;

            	    adaptor.addChild(root_0, caseexpr20.getTree());

            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);

            RBRACE21=(Token)match(input,RBRACE,FOLLOW_RBRACE_in_caselist331); 

            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "caselist"

    public static class caseexpr_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "caseexpr"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:65:1: caseexpr : ( range COLON expr -> ^( HASH range expr ) | expr );
    public final DiceParser.caseexpr_return caseexpr() throws RecognitionException {
        DiceParser.caseexpr_return retval = new DiceParser.caseexpr_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token COLON23=null;
        DiceParser.range_return range22 = null;

        DiceParser.expr_return expr24 = null;

        DiceParser.expr_return expr25 = null;


        CommonTree COLON23_tree=null;
        RewriteRuleTokenStream stream_COLON=new RewriteRuleTokenStream(adaptor,"token COLON");
        RewriteRuleSubtreeStream stream_range=new RewriteRuleSubtreeStream(adaptor,"rule range");
        RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:66:2: ( range COLON expr -> ^( HASH range expr ) | expr )
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==NUMBER) ) {
                int LA5_1 = input.LA(2);

                if ( ((LA5_1>=EACH && LA5_1<=QUESTION)||LA5_1==COMMA||LA5_1==RBRACE||(LA5_1>=COMP && LA5_1<=QUALIFIER)) ) {
                    alt5=2;
                }
                else if ( (LA5_1==DOT||LA5_1==COLON) ) {
                    alt5=1;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 5, 1, input);

                    throw nvae;
                }
            }
            else if ( ((LA5_0>=EACH && LA5_0<=MINUS)||LA5_0==QUESTION||LA5_0==COMMA||LA5_0==LPAREN||LA5_0==RBRACE||LA5_0==COMP||LA5_0==IDENTIFIER) ) {
                alt5=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;
            }
            switch (alt5) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:66:4: range COLON expr
                    {
                    pushFollow(FOLLOW_range_in_caseexpr341);
                    range22=range();

                    state._fsp--;

                    stream_range.add(range22.getTree());
                    COLON23=(Token)match(input,COLON,FOLLOW_COLON_in_caseexpr343);  
                    stream_COLON.add(COLON23);

                    pushFollow(FOLLOW_expr_in_caseexpr345);
                    expr24=expr();

                    state._fsp--;

                    stream_expr.add(expr24.getTree());


                    // AST REWRITE
                    // elements: expr, range
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 66:21: -> ^( HASH range expr )
                    {
                        // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:66:24: ^( HASH range expr )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(HASH, "HASH"), root_1);

                        adaptor.addChild(root_1, stream_range.nextTree());
                        adaptor.addChild(root_1, stream_expr.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:67:4: expr
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_expr_in_caseexpr360);
                    expr25=expr();

                    state._fsp--;

                    adaptor.addChild(root_0, expr25.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "caseexpr"

    public static class range_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "range"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:70:1: range : NUMBER ( DOT DOT NUMBER )? ;
    public final DiceParser.range_return range() throws RecognitionException {
        DiceParser.range_return retval = new DiceParser.range_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token NUMBER26=null;
        Token DOT27=null;
        Token DOT28=null;
        Token NUMBER29=null;

        CommonTree NUMBER26_tree=null;
        CommonTree DOT27_tree=null;
        CommonTree DOT28_tree=null;
        CommonTree NUMBER29_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:70:7: ( NUMBER ( DOT DOT NUMBER )? )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:70:9: NUMBER ( DOT DOT NUMBER )?
            {
            root_0 = (CommonTree)adaptor.nil();

            NUMBER26=(Token)match(input,NUMBER,FOLLOW_NUMBER_in_range370); 
            NUMBER26_tree = (CommonTree)adaptor.create(NUMBER26);
            adaptor.addChild(root_0, NUMBER26_tree);

            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:70:16: ( DOT DOT NUMBER )?
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0==DOT) ) {
                alt6=1;
            }
            switch (alt6) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:70:17: DOT DOT NUMBER
                    {
                    DOT27=(Token)match(input,DOT,FOLLOW_DOT_in_range373); 
                    DOT27_tree = (CommonTree)adaptor.create(DOT27);
                    root_0 = (CommonTree)adaptor.becomeRoot(DOT27_tree, root_0);

                    DOT28=(Token)match(input,DOT,FOLLOW_DOT_in_range376); 
                    NUMBER29=(Token)match(input,NUMBER,FOLLOW_NUMBER_in_range379); 
                    NUMBER29_tree = (CommonTree)adaptor.create(NUMBER29);
                    adaptor.addChild(root_0, NUMBER29_tree);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "range"

    public static class comparison_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "comparison"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:72:1: comparison : addsub ( COMP addsub )? ;
    public final DiceParser.comparison_return comparison() throws RecognitionException {
        DiceParser.comparison_return retval = new DiceParser.comparison_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token COMP31=null;
        DiceParser.addsub_return addsub30 = null;

        DiceParser.addsub_return addsub32 = null;


        CommonTree COMP31_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:72:12: ( addsub ( COMP addsub )? )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:72:14: addsub ( COMP addsub )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_addsub_in_comparison389);
            addsub30=addsub();

            state._fsp--;

            adaptor.addChild(root_0, addsub30.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:72:21: ( COMP addsub )?
            int alt7=2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0==COMP) ) {
                alt7=1;
            }
            switch (alt7) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:72:22: COMP addsub
                    {
                    COMP31=(Token)match(input,COMP,FOLLOW_COMP_in_comparison392); 
                    COMP31_tree = (CommonTree)adaptor.create(COMP31);
                    root_0 = (CommonTree)adaptor.becomeRoot(COMP31_tree, root_0);

                    pushFollow(FOLLOW_addsub_in_comparison395);
                    addsub32=addsub();

                    state._fsp--;

                    adaptor.addChild(root_0, addsub32.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "comparison"

    public static class addsub_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "addsub"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:74:1: addsub : ( term )? ( ( PLUS | MINUS ) term )* ;
    public final DiceParser.addsub_return addsub() throws RecognitionException {
        DiceParser.addsub_return retval = new DiceParser.addsub_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token PLUS34=null;
        Token MINUS35=null;
        DiceParser.term_return term33 = null;

        DiceParser.term_return term36 = null;


        CommonTree PLUS34_tree=null;
        CommonTree MINUS35_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:2: ( ( term )? ( ( PLUS | MINUS ) term )* )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:4: ( term )? ( ( PLUS | MINUS ) term )*
            {
            root_0 = (CommonTree)adaptor.nil();

            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:4: ( term )?
            int alt8=2;
            int LA8_0 = input.LA(1);

            if ( (LA8_0==LPAREN||LA8_0==NUMBER||LA8_0==IDENTIFIER) ) {
                alt8=1;
            }
            switch (alt8) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:4: term
                    {
                    pushFollow(FOLLOW_term_in_addsub408);
                    term33=term();

                    state._fsp--;

                    adaptor.addChild(root_0, term33.getTree());

                    }
                    break;

            }

            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:10: ( ( PLUS | MINUS ) term )*
            loop10:
            do {
                int alt10=2;
                int LA10_0 = input.LA(1);

                if ( ((LA10_0>=PLUS && LA10_0<=MINUS)) ) {
                    alt10=1;
                }


                switch (alt10) {
            	case 1 :
            	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:12: ( PLUS | MINUS ) term
            	    {
            	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:12: ( PLUS | MINUS )
            	    int alt9=2;
            	    int LA9_0 = input.LA(1);

            	    if ( (LA9_0==PLUS) ) {
            	        alt9=1;
            	    }
            	    else if ( (LA9_0==MINUS) ) {
            	        alt9=2;
            	    }
            	    else {
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 9, 0, input);

            	        throw nvae;
            	    }
            	    switch (alt9) {
            	        case 1 :
            	            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:14: PLUS
            	            {
            	            PLUS34=(Token)match(input,PLUS,FOLLOW_PLUS_in_addsub415); 
            	            PLUS34_tree = (CommonTree)adaptor.create(PLUS34);
            	            root_0 = (CommonTree)adaptor.becomeRoot(PLUS34_tree, root_0);


            	            }
            	            break;
            	        case 2 :
            	            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:75:22: MINUS
            	            {
            	            MINUS35=(Token)match(input,MINUS,FOLLOW_MINUS_in_addsub420); 
            	            MINUS35_tree = (CommonTree)adaptor.create(MINUS35);
            	            root_0 = (CommonTree)adaptor.becomeRoot(MINUS35_tree, root_0);


            	            }
            	            break;

            	    }

            	    pushFollow(FOLLOW_term_in_addsub426);
            	    term36=term();

            	    state._fsp--;

            	    adaptor.addChild(root_0, term36.getTree());

            	    }
            	    break;

            	default :
            	    break loop10;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "addsub"

    public static class term_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "term"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:77:1: term : multdiv ( QUALIFIER )? ;
    public final DiceParser.term_return term() throws RecognitionException {
        DiceParser.term_return retval = new DiceParser.term_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token QUALIFIER38=null;
        DiceParser.multdiv_return multdiv37 = null;


        CommonTree QUALIFIER38_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:77:6: ( multdiv ( QUALIFIER )? )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:77:8: multdiv ( QUALIFIER )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_multdiv_in_term438);
            multdiv37=multdiv();

            state._fsp--;

            adaptor.addChild(root_0, multdiv37.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:77:16: ( QUALIFIER )?
            int alt11=2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0==QUALIFIER) ) {
                alt11=1;
            }
            switch (alt11) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:77:17: QUALIFIER
                    {
                    QUALIFIER38=(Token)match(input,QUALIFIER,FOLLOW_QUALIFIER_in_term441); 
                    QUALIFIER38_tree = (CommonTree)adaptor.create(QUALIFIER38);
                    adaptor.addChild(root_0, QUALIFIER38_tree);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "term"

    public static class multdiv_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "multdiv"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:1: multdiv : factor ( ( MULT | DIV ) factor )* ;
    public final DiceParser.multdiv_return multdiv() throws RecognitionException {
        DiceParser.multdiv_return retval = new DiceParser.multdiv_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token MULT40=null;
        Token DIV41=null;
        DiceParser.factor_return factor39 = null;

        DiceParser.factor_return factor42 = null;


        CommonTree MULT40_tree=null;
        CommonTree DIV41_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:9: ( factor ( ( MULT | DIV ) factor )* )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:11: factor ( ( MULT | DIV ) factor )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_factor_in_multdiv453);
            factor39=factor();

            state._fsp--;

            adaptor.addChild(root_0, factor39.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:18: ( ( MULT | DIV ) factor )*
            loop13:
            do {
                int alt13=2;
                int LA13_0 = input.LA(1);

                if ( ((LA13_0>=MULT && LA13_0<=DIV)) ) {
                    alt13=1;
                }


                switch (alt13) {
            	case 1 :
            	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:20: ( MULT | DIV ) factor
            	    {
            	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:20: ( MULT | DIV )
            	    int alt12=2;
            	    int LA12_0 = input.LA(1);

            	    if ( (LA12_0==MULT) ) {
            	        alt12=1;
            	    }
            	    else if ( (LA12_0==DIV) ) {
            	        alt12=2;
            	    }
            	    else {
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 12, 0, input);

            	        throw nvae;
            	    }
            	    switch (alt12) {
            	        case 1 :
            	            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:22: MULT
            	            {
            	            MULT40=(Token)match(input,MULT,FOLLOW_MULT_in_multdiv459); 
            	            MULT40_tree = (CommonTree)adaptor.create(MULT40);
            	            root_0 = (CommonTree)adaptor.becomeRoot(MULT40_tree, root_0);


            	            }
            	            break;
            	        case 2 :
            	            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:79:30: DIV
            	            {
            	            DIV41=(Token)match(input,DIV,FOLLOW_DIV_in_multdiv464); 
            	            DIV41_tree = (CommonTree)adaptor.create(DIV41);
            	            root_0 = (CommonTree)adaptor.becomeRoot(DIV41_tree, root_0);


            	            }
            	            break;

            	    }

            	    pushFollow(FOLLOW_factor_in_multdiv469);
            	    factor42=factor();

            	    state._fsp--;

            	    adaptor.addChild(root_0, factor42.getTree());

            	    }
            	    break;

            	default :
            	    break loop13;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "multdiv"

    public static class factor_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "factor"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:1: factor : reference ( ( D | CD ) reference ( opts )* )? ;
    public final DiceParser.factor_return factor() throws RecognitionException {
        DiceParser.factor_return retval = new DiceParser.factor_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token set44=null;
        DiceParser.reference_return reference43 = null;

        DiceParser.reference_return reference45 = null;

        DiceParser.opts_return opts46 = null;


        CommonTree set44_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:8: ( reference ( ( D | CD ) reference ( opts )* )? )
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:10: reference ( ( D | CD ) reference ( opts )* )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_reference_in_factor481);
            reference43=reference();

            state._fsp--;

            adaptor.addChild(root_0, reference43.getTree());
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:20: ( ( D | CD ) reference ( opts )* )?
            int alt15=2;
            int LA15_0 = input.LA(1);

            if ( ((LA15_0>=D && LA15_0<=CD)) ) {
                alt15=1;
            }
            switch (alt15) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:22: ( D | CD ) reference ( opts )*
                    {
                    set44=(Token)input.LT(1);
                    set44=(Token)input.LT(1);
                    if ( (input.LA(1)>=D && input.LA(1)<=CD) ) {
                        input.consume();
                        root_0 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(set44), root_0);
                        state.errorRecovery=false;
                    }
                    else {
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }

                    pushFollow(FOLLOW_reference_in_factor494);
                    reference45=reference();

                    state._fsp--;

                    adaptor.addChild(root_0, reference45.getTree());
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:42: ( opts )*
                    loop14:
                    do {
                        int alt14=2;
                        int LA14_0 = input.LA(1);

                        if ( (LA14_0==LBRACE||(LA14_0>=HIGH && LA14_0<=ROLLAGAIN)) ) {
                            alt14=1;
                        }


                        switch (alt14) {
                    	case 1 :
                    	    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:81:43: opts
                    	    {
                    	    pushFollow(FOLLOW_opts_in_factor497);
                    	    opts46=opts();

                    	    state._fsp--;

                    	    adaptor.addChild(root_0, opts46.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop14;
                        }
                    } while (true);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "factor"

    public static class opts_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "opts"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:83:1: opts : ( HIGH reference | LOW reference | REROLL range | ROLLAGAIN range | caselist );
    public final DiceParser.opts_return opts() throws RecognitionException {
        DiceParser.opts_return retval = new DiceParser.opts_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token HIGH47=null;
        Token LOW49=null;
        Token REROLL51=null;
        Token ROLLAGAIN53=null;
        DiceParser.reference_return reference48 = null;

        DiceParser.reference_return reference50 = null;

        DiceParser.range_return range52 = null;

        DiceParser.range_return range54 = null;

        DiceParser.caselist_return caselist55 = null;


        CommonTree HIGH47_tree=null;
        CommonTree LOW49_tree=null;
        CommonTree REROLL51_tree=null;
        CommonTree ROLLAGAIN53_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:83:7: ( HIGH reference | LOW reference | REROLL range | ROLLAGAIN range | caselist )
            int alt16=5;
            switch ( input.LA(1) ) {
            case HIGH:
                {
                alt16=1;
                }
                break;
            case LOW:
                {
                alt16=2;
                }
                break;
            case REROLL:
                {
                alt16=3;
                }
                break;
            case ROLLAGAIN:
                {
                alt16=4;
                }
                break;
            case LBRACE:
                {
                alt16=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 16, 0, input);

                throw nvae;
            }

            switch (alt16) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:83:9: HIGH reference
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    HIGH47=(Token)match(input,HIGH,FOLLOW_HIGH_in_opts512); 
                    HIGH47_tree = (CommonTree)adaptor.create(HIGH47);
                    root_0 = (CommonTree)adaptor.becomeRoot(HIGH47_tree, root_0);

                    pushFollow(FOLLOW_reference_in_opts515);
                    reference48=reference();

                    state._fsp--;

                    adaptor.addChild(root_0, reference48.getTree());

                    }
                    break;
                case 2 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:84:4: LOW reference
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    LOW49=(Token)match(input,LOW,FOLLOW_LOW_in_opts520); 
                    LOW49_tree = (CommonTree)adaptor.create(LOW49);
                    root_0 = (CommonTree)adaptor.becomeRoot(LOW49_tree, root_0);

                    pushFollow(FOLLOW_reference_in_opts523);
                    reference50=reference();

                    state._fsp--;

                    adaptor.addChild(root_0, reference50.getTree());

                    }
                    break;
                case 3 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:85:4: REROLL range
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    REROLL51=(Token)match(input,REROLL,FOLLOW_REROLL_in_opts528); 
                    REROLL51_tree = (CommonTree)adaptor.create(REROLL51);
                    root_0 = (CommonTree)adaptor.becomeRoot(REROLL51_tree, root_0);

                    pushFollow(FOLLOW_range_in_opts531);
                    range52=range();

                    state._fsp--;

                    adaptor.addChild(root_0, range52.getTree());

                    }
                    break;
                case 4 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:86:4: ROLLAGAIN range
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    ROLLAGAIN53=(Token)match(input,ROLLAGAIN,FOLLOW_ROLLAGAIN_in_opts536); 
                    ROLLAGAIN53_tree = (CommonTree)adaptor.create(ROLLAGAIN53);
                    root_0 = (CommonTree)adaptor.becomeRoot(ROLLAGAIN53_tree, root_0);

                    pushFollow(FOLLOW_range_in_opts539);
                    range54=range();

                    state._fsp--;

                    adaptor.addChild(root_0, range54.getTree());

                    }
                    break;
                case 5 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:87:4: caselist
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_caselist_in_opts544);
                    caselist55=caselist();

                    state._fsp--;

                    adaptor.addChild(root_0, caselist55.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "opts"

    public static class reference_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "reference"
    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:90:1: reference : ( LPAREN altExpr RPAREN | IDENTIFIER | NUMBER );
    public final DiceParser.reference_return reference() throws RecognitionException {
        DiceParser.reference_return retval = new DiceParser.reference_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token LPAREN56=null;
        Token RPAREN58=null;
        Token IDENTIFIER59=null;
        Token NUMBER60=null;
        DiceParser.altExpr_return altExpr57 = null;


        CommonTree LPAREN56_tree=null;
        CommonTree RPAREN58_tree=null;
        CommonTree IDENTIFIER59_tree=null;
        CommonTree NUMBER60_tree=null;

        try {
            // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:91:2: ( LPAREN altExpr RPAREN | IDENTIFIER | NUMBER )
            int alt17=3;
            switch ( input.LA(1) ) {
            case LPAREN:
                {
                alt17=1;
                }
                break;
            case IDENTIFIER:
                {
                alt17=2;
                }
                break;
            case NUMBER:
                {
                alt17=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 17, 0, input);

                throw nvae;
            }

            switch (alt17) {
                case 1 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:91:4: LPAREN altExpr RPAREN
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    LPAREN56=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_reference557); 
                    LPAREN56_tree = (CommonTree)adaptor.create(LPAREN56);
                    root_0 = (CommonTree)adaptor.becomeRoot(LPAREN56_tree, root_0);

                    pushFollow(FOLLOW_altExpr_in_reference560);
                    altExpr57=altExpr();

                    state._fsp--;

                    adaptor.addChild(root_0, altExpr57.getTree());
                    RPAREN58=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_reference562); 

                    }
                    break;
                case 2 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:92:4: IDENTIFIER
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    IDENTIFIER59=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_reference568); 
                    IDENTIFIER59_tree = (CommonTree)adaptor.create(IDENTIFIER59);
                    adaptor.addChild(root_0, IDENTIFIER59_tree);


                    }
                    break;
                case 3 :
                    // C:\\Users\\Joe\\workspace\\eclipse\\area42dice\\grammar\\Dice.g:93:4: NUMBER
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    NUMBER60=(Token)match(input,NUMBER,FOLLOW_NUMBER_in_reference573); 
                    NUMBER60_tree = (CommonTree)adaptor.create(NUMBER60);
                    adaptor.addChild(root_0, NUMBER60_tree);


                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "reference"

    // Delegated rules


 

    public static final BitSet FOLLOW_expr_in_exprList223 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_SEMI_in_exprList225 = new BitSet(new long[]{0x00000000106100C2L});
    public static final BitSet FOLLOW_altExpr_in_expr242 = new BitSet(new long[]{0x0000000000000022L});
    public static final BitSet FOLLOW_EACH_in_expr245 = new BitSet(new long[]{0x00000000106100C0L});
    public static final BitSet FOLLOW_altExpr_in_expr248 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_comparison_in_altExpr262 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_QUESTION_in_altExpr266 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_caselist_in_altExpr269 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_QUESTION_in_altExpr273 = new BitSet(new long[]{0x00000000106180C0L});
    public static final BitSet FOLLOW_thenElse_in_altExpr276 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_altExpr_in_thenElse288 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_COLON_in_thenElse290 = new BitSet(new long[]{0x00000000106100C0L});
    public static final BitSet FOLLOW_altExpr_in_thenElse293 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_factor_in_eachExpr302 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_EACH_in_eachExpr304 = new BitSet(new long[]{0x00000000106100C0L});
    public static final BitSet FOLLOW_altExpr_in_eachExpr307 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LBRACE_in_caselist318 = new BitSet(new long[]{0x00000000106100C0L});
    public static final BitSet FOLLOW_caseexpr_in_caselist321 = new BitSet(new long[]{0x0000000000084000L});
    public static final BitSet FOLLOW_COMMA_in_caselist324 = new BitSet(new long[]{0x00000000106100C0L});
    public static final BitSet FOLLOW_caseexpr_in_caselist327 = new BitSet(new long[]{0x0000000000084000L});
    public static final BitSet FOLLOW_RBRACE_in_caselist331 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_range_in_caseexpr341 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_COLON_in_caseexpr343 = new BitSet(new long[]{0x00000000106100C0L});
    public static final BitSet FOLLOW_expr_in_caseexpr345 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expr_in_caseexpr360 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NUMBER_in_range370 = new BitSet(new long[]{0x0000000000002002L});
    public static final BitSet FOLLOW_DOT_in_range373 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_DOT_in_range376 = new BitSet(new long[]{0x0000000000200000L});
    public static final BitSet FOLLOW_NUMBER_in_range379 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_addsub_in_comparison389 = new BitSet(new long[]{0x0000000000400002L});
    public static final BitSet FOLLOW_COMP_in_comparison392 = new BitSet(new long[]{0x00000000102100C0L});
    public static final BitSet FOLLOW_addsub_in_comparison395 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_addsub408 = new BitSet(new long[]{0x00000000000000C2L});
    public static final BitSet FOLLOW_PLUS_in_addsub415 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_MINUS_in_addsub420 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_term_in_addsub426 = new BitSet(new long[]{0x00000000000000C2L});
    public static final BitSet FOLLOW_multdiv_in_term438 = new BitSet(new long[]{0x0000000000800002L});
    public static final BitSet FOLLOW_QUALIFIER_in_term441 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_factor_in_multdiv453 = new BitSet(new long[]{0x0000000000000302L});
    public static final BitSet FOLLOW_MULT_in_multdiv459 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_DIV_in_multdiv464 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_factor_in_multdiv469 = new BitSet(new long[]{0x0000000000000302L});
    public static final BitSet FOLLOW_reference_in_factor481 = new BitSet(new long[]{0x0000000000000C02L});
    public static final BitSet FOLLOW_set_in_factor485 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_reference_in_factor494 = new BitSet(new long[]{0x000000000F040002L});
    public static final BitSet FOLLOW_opts_in_factor497 = new BitSet(new long[]{0x000000000F040002L});
    public static final BitSet FOLLOW_HIGH_in_opts512 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_reference_in_opts515 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LOW_in_opts520 = new BitSet(new long[]{0x0000000010210000L});
    public static final BitSet FOLLOW_reference_in_opts523 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_REROLL_in_opts528 = new BitSet(new long[]{0x0000000000200000L});
    public static final BitSet FOLLOW_range_in_opts531 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ROLLAGAIN_in_opts536 = new BitSet(new long[]{0x0000000000200000L});
    public static final BitSet FOLLOW_range_in_opts539 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_caselist_in_opts544 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LPAREN_in_reference557 = new BitSet(new long[]{0x00000000106300C0L});
    public static final BitSet FOLLOW_altExpr_in_reference560 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_RPAREN_in_reference562 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_reference568 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NUMBER_in_reference573 = new BitSet(new long[]{0x0000000000000002L});

}